using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Toon.Models.Characters;

namespace Toon.Models.Tests.Characters
{
    
	public partial class PossessionTests
	{

		Dictionary<string, object> GetValues(Toon.Models.Characters.Possession objectUnderTest)
		{
			
			var result = new Dictionary<string, object>();
			result["Name"] = objectUnderTest.Name;
			result["Type"] = objectUnderTest.Type;
			result["Notes"] = objectUnderTest.Notes;
			result["IsChanged"] = objectUnderTest.IsChanged;
			result["HasErrors"] = objectUnderTest.HasErrors;
			return result;
		}

		List<string> GetDiffs(Dictionary<string, object> originalValues, Toon.Models.Characters.Possession objectUnderTest)
		{
			return GetDiffs(originalValues, GetValues(objectUnderTest));
		}

		List<string> GetDiffs(Dictionary<string, object> originalValues, Dictionary<string, object> newValues)
		{
			var result = new List<string>();
			foreach(var item in originalValues)
			{
				if (!Object.Equals(item.Value, newValues[item.Key]))
					result.Add(item.Key);
			}

			return result;
		}

		public Toon.Models.Characters.Possession GetObject(int version)
		{
			var objectUnderTest = CreateObject();
			SetValues(objectUnderTest, version);
			return objectUnderTest;
		}

		public void SetValues(Toon.Models.Characters.Possession objectUnderTest, int version)
		{
			
			Helper_Set_Name(objectUnderTest, version);
			Helper_Set_Notes(objectUnderTest, version);
		}

        
		//implement this to provide a custom list of known good values
		partial void Helper_SetOverride_Name(Toon.Models.Characters.Possession objectUnderTest, int version, ref bool wasSet);

        void Helper_Set_Name (Toon.Models.Characters.Possession objectUnderTest, int version)
        {
			var wasSet = false;
			Helper_SetOverride_Name(objectUnderTest, version, ref wasSet);
			if (wasSet)
				return;

			var successCount = 0;
        
            
            try
            {
                objectUnderTest.Name = null;
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "1";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "x";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = ",";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "123";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "abc";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "1,2,3";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "a,b,c";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "1;2;3";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "a;b;c";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "http://test.com";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Name = "test@test.com";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
        
			if (successCount == 0)
				Assert.Inconclusive("Could not complete test, unable to set the property."); 			
			else
				Helper_Set_Name(objectUnderTest, version-successCount);
        }    
        
        
		//implement this to provide a custom list of known good values
		partial void Helper_SetOverride_Notes(Toon.Models.Characters.Possession objectUnderTest, int version, ref bool wasSet);

        void Helper_Set_Notes (Toon.Models.Characters.Possession objectUnderTest, int version)
        {
			var wasSet = false;
			Helper_SetOverride_Notes(objectUnderTest, version, ref wasSet);
			if (wasSet)
				return;

			var successCount = 0;
        
            
            try
            {
                objectUnderTest.Notes = null;
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "1";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "x";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = ",";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "123";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "abc";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "1,2,3";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "a,b,c";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "1;2;3";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "a;b;c";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "http://test.com";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
            
            try
            {
                objectUnderTest.Notes = "test@test.com";
                successCount += 1;
				if (successCount == version)
					return;
            }
            catch (ArgumentException)
            {
                //Try the next value
            }
            
        
			if (successCount == 0)
				Assert.Inconclusive("Could not complete test, unable to set the property."); 			
			else
				Helper_Set_Notes(objectUnderTest, version-successCount);
        }    
        


	}
}
